package com.struts.deal.user.register;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibatis.po.user.TSubStation;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.lg.system.CSqlMap;
import com.base.BaseLog;
import java.util.List;

public class BaseInfoDeal extends BaseLog {

	
	public static  void checkLoginName(HttpServletRequest request,
            HttpServletResponse response){
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
    	try{
        	String lname= "";
        	String lnametemp= request.getParameter("lname");
        	if(lnametemp.length()>0 && lnametemp != null){
        		lname=lnametemp;
        	}
        	response.setCharacterEncoding("UTF-8");
        	PrintWriter out = response.getWriter();
        	int count = 0;
        	count = ((Integer)sqlmap.queryForObject("T_USER_INFO.selectByloginName",lname)).intValue();
        	if(count>0){
        		
        		out.print("对不起，该用户已被使用！");
        	}else{
        		out.print("恭喜你，该用户未被使用！");
        	}
        	}catch(Exception e){
        		logger.info("验证用户是否存在是发生错误!\n");
        		e.printStackTrace();
        	}
    	
    	
    }
	public static  void getSubStation(HttpServletRequest request,
            HttpServletResponse response){
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		List subStationList = null;
		TSubStation subStationPo = new TSubStation();
    	try{
        	String sortId= "";
        	String temp= request.getParameter("selected");
        	if(temp.length()>0 && temp != null){
        		sortId=temp;
        	}
        	response.setCharacterEncoding("UTF-8");
        	PrintWriter out = response.getWriter();
        	
        	subStationList = sqlmap.queryForList("T_SUB_STATION.selectBySortId",sortId);
        	for(int i=0;i<subStationList.size();i++){
				subStationPo = (TSubStation)subStationList.get(i);
				out.println("<option value="+subStationPo.getId()+">"+subStationPo.getPostName()+"</option>");
			}
        	}catch(Exception e){
        		e.printStackTrace();
        	}
    	
    	
    }
}
